<template>
  <div class="windows_top">
    <div class="windows_top_box">
      <span class="selected_none">新的朋友</span>
    </div>
  </div>
  <div class="windows_new_friends">
    <el-scrollbar>
      <div v-for="(friend,index) in newFriendList"
        :key="friend.user_id" class="new_friends_item">
        <div class="friends_img">
          <img :src="friend.avatar" alt="">
        </div>
        <div class="friends_info">
          <p class="friends_info_name">{{ friend.realname }}
          </p>
          <p class="friends_info_content">
            {{ friend.content }}</p>
        </div>
        <div class="friends_oprate">
          <span class="friends_opreate_result"
            v-if="friend.status===2">已添加</span>
          <span class="friends_opreate_result"
            v-if="friend.status===1">已拒绝</span>
          <button class="friends_opreate_btn"
            v-if="friend.status===0"
            @click="handleFriendRelation(friend,2)">添加
          </button>
          <button class="friends_opreate_btn ml_6"
            v-if="friend.status===0"
            @click="handleFriendRelation(friend,1)">拒绝
          </button>
        </div>
      </div>
    </el-scrollbar>
  </div>
</template>

<script>
import { defineComponent, onMounted, computed } from "vue";
import { useChatStore } from "../../../store/chat";

export default defineComponent({
  name: "new-friend",
  setup() {
    const chatStore = useChatStore();
    const newFriendList = computed(() => chatStore.newFriendList);
    const handleFriendRelation = (friend, status) => {};
    const handleInit = async () => {};
    onMounted(() => {
      handleInit();
    });
    return {
      newFriendList,
      handleInit,
      handleFriendRelation,
    };
  },
});
</script>

<style lang="less" scoped>
@import "src/pages/wechat/wechat.less";
.windows_top {
  padding-top: 10px;
  height: 62px;
  border-bottom: 1px solid #e7e7e7;

  .windows_top_box {
    width: 100%;
    height: 100%;
    position: relative;

    & > span {
      font-size: 18px;
      color: #333;
      line-height: 52px;
      padding-left: 30px;
      display: inline-block;
    }
  }
}
.windows_new_friends {
  height: calc(100% - 62px);

  .new_friends_item {
    display: flex;
    padding: 18px 0;
    margin: 0 40px;
    border-bottom: 1px solid #e5e5e5;
    align-items: center;
    color: #333;

    .friends_img {
      flex: 0 0 40px;
      height: 40px;

      img {
        width: 40px;
      }
    }

    .friends_info {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding: 0 12px;

      .friends_info_name {
        color: #000;
        font-size: 16px;
        padding-bottom: 10px;
      }

      .friends_info_content {
        font-size: 12px;
      }
    }

    .friends_oprate {
      .friends_opreate_result {
        font-size: 14px;
      }

      .friends_opreate_btn {
        font-size: 14px;
        padding: 4px 8px;
        outline: 0;
        height: 26px;
        cursor: pointer;
        background: #09bb07;
        color: #fff;
        border: 1px solid #09bb07;
      }
    }
  }
}
</style>